package com.example.xm.controller;

import com.example.xm.Entity.Pl2;
import com.example.xm.servive.Pl2Servive;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/P2")
public class Pl2Controller {
    @Autowired
    Pl2Servive pl2Servive;

    /**显示*/
    @PostMapping("/spper")
    public List<Pl2> Students(@RequestBody Pl2 pl2){
        System.out.println(pl2Servive.getAllPl2(pl2));
        return pl2Servive.getAllPl2(pl2);
    }
    /**添加评论*/
    @PostMapping("")
    public int AddPl(@RequestBody Pl2 pl2){
        pl2.setPl2_date(new Date());
        System.out.println("添加了：" + pl2);
        return pl2Servive.AddPl2(pl2);
    }
}
